package com.lance.answer.question_export;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.lance.answer.dto.Item;
import com.lance.answer.gui.answer.Question;
import com.lance.answer.gui.answer.Util;
import com.lance.answer.gui.answer.gk.DealInfoUtil;
import com.lance.answer.section_import.SectionImport;
import com.lance.answer.util.CollectionsUtil;
import com.lance.answer.util.MD5Utils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.io.File;
import java.io.FileInputStream;
import java.time.Duration;
import java.util.*;

/**
 * <p>以老师的身份获取答案<p>
 *
 * @author : fengx
 * @since JDK8.0
 * <p>
 * <p>
 * 后面
 * 选择题、单元自测题、计分、分、自测、综合练习 都要获取
 * create by fengx on 2021/7/15 14:47
 */
public class GetAnswerByTeacher3Batch2 {

    public static void login(WebDriver driver, String userName, String pwd) {
        WebElement agreeButton = driver.findElement(By.id("RememberLogin"));
        agreeButton.click();

        WebElement userNameInput = driver.findElement(By.id("username"));
        userNameInput.clear();
        userNameInput.sendKeys(userName);

        WebElement passwordInput = driver.findElement(By.id("password"));
        passwordInput.clear();
        passwordInput.sendKeys(pwd);


        WebElement loginBtn = driver.findElement(By.name("button"));

        loginBtn.click();
    }

    public static void main(String[] args) throws Exception {
        ChromeDriver driver = Util.getDriver(null);
        String url = "http://thome.ouchn.cn/";
        driver.get(url);
        Thread.sleep(3000);
//        String userName = "zsxypy_1";
//        String pwd = "zsxypy_1";
        String userName = "zsxypy_1";
        String pwd = "zsxypy_1";

        // start 2022-6-12 19:10
        // 统计学原理
        Map<String, String> SUBJECT = Maps.newHashMap();

        SUBJECT.put("劳动与社会保障法","劳动与社会保障法");
        SUBJECT.put("JavaScript程序设计","JavaScript程序设计");
        SUBJECT.put("电算化会计","电算化会计");
        SUBJECT.put("现代管理原理","现代管理原理");
        SUBJECT.put("高级财务会计","高级财务会计");
        SUBJECT.put("货币银行学","货币银行学");
        SUBJECT.put("金融市场","金融市场");
        SUBJECT.put("基础会计","基础会计");
        SUBJECT.put("现代汉语(2)","现代汉语(2)");
        SUBJECT.put("阅读与写作(2)","阅读与写作(2)");
        SUBJECT.put("软件工程","软件工程");
        SUBJECT.put("金融企业会计","金融企业会计");
        SUBJECT.put("MySQL数据库应用","MySQL数据库应用");
        SUBJECT.put("旅游法规","旅游法规");
        SUBJECT.put("互联网金融概论","互联网金融概论");
        SUBJECT.put("房屋建筑混凝土结构设计","房屋建筑混凝土结构设计");
        SUBJECT.put("古代诗歌散文专题","古代诗歌散文专题");
        SUBJECT.put("医学生物化学","医学生物化学");
        SUBJECT.put("法理学","法理学");
        SUBJECT.put("自然科学基础","自然科学基础");
        SUBJECT.put("中文学科论文写作","中文学科论文写作");
        SUBJECT.put("国际公法","国际公法");
        SUBJECT.put("工程经济与管理","工程经济与管理");
        SUBJECT.put("药物化学","药物化学");
        SUBJECT.put("习近平总书记教育重要论述研究","习近平总书记教育重要论述研究");
        SUBJECT.put("医学免疫学与微生物学","医学免疫学与微生物学");
        SUBJECT.put("政治经济学","政治经济学");
        SUBJECT.put("新疆历史与民族宗教理论政策教程","新疆历史与民族宗教理论政策教程");
        SUBJECT.put("水法规与行政执法","水法规与行政执法");
        SUBJECT.put("管理心理学","管理心理学");
        SUBJECT.put("分析化学（本）","分析化学（本）");
        SUBJECT.put("中级财务会计（一）","中级财务会计（一）");
        SUBJECT.put("阅读与写作(1)","阅读与写作(1)");
        SUBJECT.put("计算机平面设计(1)","计算机平面设计(1)");
        SUBJECT.put("数据库基础与应用","数据库基础与应用");
        SUBJECT.put("外科护理学","外科护理学");
        SUBJECT.put("房屋构造与维护管理","房屋构造与维护管理");
        SUBJECT.put("数据库运维","数据库运维");
        SUBJECT.put("审计学","审计学");
        SUBJECT.put("理工英语1","理工英语1");
        SUBJECT.put("理工英语2","理工英语2");
        SUBJECT.put("金融基础","金融基础");
        SUBJECT.put("科学与技术","科学与技术");
        SUBJECT.put("护理科研方法","护理科研方法");
        SUBJECT.put("药理学","药理学");
        SUBJECT.put("学前儿童语言教育","学前儿童语言教育");
        SUBJECT.put("金融法规","金融法规");
        SUBJECT.put("中国当代文学","中国当代文学");
        SUBJECT.put("人体生理学","人体生理学");
        SUBJECT.put("理工英语3","理工英语3");
        SUBJECT.put("理工英语4","理工英语4");
        SUBJECT.put("网络实用技术基础","网络实用技术基础");
        SUBJECT.put("商法","商法");
        SUBJECT.put("计算机专业指南(专)","计算机专业指南(专)");
        SUBJECT.put("调剂学（本）","调剂学（本）");
        SUBJECT.put("内科护理学（本）","内科护理学（本）");
        SUBJECT.put("社会调查研究与方法","社会调查研究与方法");
        SUBJECT.put("西方经济学（本）","西方经济学（本）");
        SUBJECT.put("组织行为学","组织行为学");
        SUBJECT.put("小学语文教学研究","小学语文教学研究");
        SUBJECT.put("人文社会科学基础","人文社会科学基础");
        SUBJECT.put("心理学","心理学");
        SUBJECT.put("医药商品营销实务","医药商品营销实务");
        SUBJECT.put("学前儿童科学教育","学前儿童科学教育");
        SUBJECT.put("外科护理学（本）","外科护理学（本）");
        SUBJECT.put("药物治疗学","药物治疗学");
        SUBJECT.put("健康评估","健康评估");
        SUBJECT.put("信息技术与教育技术(1)","信息技术与教育技术(1)");
        SUBJECT.put("古代小说戏曲专题","古代小说戏曲专题");
        SUBJECT.put("行政领导学","行政领导学");
        SUBJECT.put("国际经济法","国际经济法");
       // SUBJECT.put("机械CAD/CAM","机械CAD/CAM");
        SUBJECT.put("现代汉语(1)","现代汉语(1)");
        SUBJECT.put("民法学(1)","民法学(1)");
        SUBJECT.put("刑法学(1)","刑法学(1)");
        SUBJECT.put("小企业管理","小企业管理");
        SUBJECT.put("土木工程力学（本）","土木工程力学（本）");
        SUBJECT.put("护理学基础","护理学基础");
        SUBJECT.put("健康教育与健康促进","健康教育与健康促进");
        SUBJECT.put("社会保障学","社会保障学");
        SUBJECT.put("投资学","投资学");
        SUBJECT.put("外国文学","外国文学");
        SUBJECT.put("学前教育原理","学前教育原理");
        SUBJECT.put("机电控制与可编程序控制器技术","机电控制与可编程序控制器技术");
        SUBJECT.put("社会心理适应","社会心理适应");
        SUBJECT.put("企业金融行为","企业金融行为");
        SUBJECT.put("管理学基础","管理学基础");
        SUBJECT.put("建筑工程质量检验","建筑工程质量检验");
        SUBJECT.put("计算机网络（本）","计算机网络（本）");
        SUBJECT.put("美学原理","美学原理");
        SUBJECT.put("企业信息管理","企业信息管理");
        SUBJECT.put("中国现代文学专题","中国现代文学专题");
        SUBJECT.put("建筑工程计量与计价","建筑工程计量与计价");
        SUBJECT.put("公司财务","公司财务");
        SUBJECT.put("中国古代文学(B)(1)","中国古代文学(B)(1)");
        SUBJECT.put("成本管理","成本管理");
        SUBJECT.put("计算机组网技术","计算机组网技术");
        SUBJECT.put("数学思想与方法","数学思想与方法");
        SUBJECT.put("药事管理与法规","药事管理与法规");
        SUBJECT.put("计算机组成原理","计算机组成原理");
        SUBJECT.put("公共部门人力资源管理","公共部门人力资源管理");
        SUBJECT.put("医护心理学","医护心理学");
        SUBJECT.put("计算机应用基础(本)","计算机应用基础(本)");
        SUBJECT.put("微积分基础","微积分基础");
        SUBJECT.put("网络应用服务管理","网络应用服务管理");
        SUBJECT.put("中央银行理论与实务","中央银行理论与实务");
        SUBJECT.put("经济法学","经济法学");
        SUBJECT.put("药物治疗学（本）","药物治疗学（本）");
        SUBJECT.put("小学数学教学研究","小学数学教学研究");
        SUBJECT.put("素描","素描");
        SUBJECT.put("视觉设计基础","视觉设计基础");
        SUBJECT.put("中国当代文学专题","中国当代文学专题");
        SUBJECT.put("药理学（本）","药理学（本）");
        SUBJECT.put("中国特色社会主义理论体系概论","中国特色社会主义理论体系概论");
        SUBJECT.put("经济学基础","经济学基础");
        SUBJECT.put("建设项目管理","建设项目管理");
        SUBJECT.put("经济学与生活","经济学与生活");
        SUBJECT.put("可编程控制器应用","可编程控制器应用");
        SUBJECT.put("幼儿游戏与玩具","幼儿游戏与玩具");
        SUBJECT.put("大学语文（1）","大学语文（1）");
        SUBJECT.put("电气传动与调速系统","电气传动与调速系统");
        SUBJECT.put("人力资源管理","人力资源管理");
        SUBJECT.put("思想道德与法治","思想道德与法治");
        SUBJECT.put("调剂学","调剂学");
        SUBJECT.put("会计制度设计","会计制度设计");
        SUBJECT.put("网站界面（UI）设计","网站界面（UI）设计");
        SUBJECT.put("药剂学（本）","药剂学（本）");
        SUBJECT.put("建筑测量","建筑测量");
        SUBJECT.put("Flash动画制作","Flash动画制作");
        SUBJECT.put("市场营销学","市场营销学");
        SUBJECT.put("财务报表分析","财务报表分析");
        SUBJECT.put("操作系统","操作系统");
        SUBJECT.put("人类与社会","人类与社会");
        SUBJECT.put("电工电子技术","电工电子技术");
        SUBJECT.put("会计学概论","会计学概论");
        SUBJECT.put("Python程序设计","Python程序设计");
        SUBJECT.put("机械制图","机械制图");
        SUBJECT.put("现代汉语专题","现代汉语专题");
        SUBJECT.put("学前教育科研方法","学前教育科研方法");
        SUBJECT.put("计算机平面设计(2)","计算机平面设计(2)");
        SUBJECT.put("旅行社经营管理","旅行社经营管理");
        SUBJECT.put("药理学（药）","药理学（药）");
        SUBJECT.put("儿童家庭教育指导","儿童家庭教育指导");
        SUBJECT.put("文献检索","文献检索");
        SUBJECT.put("幼儿园教育质量评价","幼儿园教育质量评价");
    //    SUBJECT.put("民族理论与民族政策","民族理论与民族政策");
        SUBJECT.put("旅游经济学","旅游经济学");
        SUBJECT.put("ERP原理与应用","ERP原理与应用");
        SUBJECT.put("土木工程CAD","土木工程CAD");
        SUBJECT.put("政治学原理","政治学原理");
        SUBJECT.put("计算机文化基础","计算机文化基础");
        SUBJECT.put("企业班组长通用能力课程","企业班组长通用能力课程");
        SUBJECT.put("现代货币金融学说","现代货币金融学说");
        SUBJECT.put("建筑材料(A)","建筑材料(A)");
        SUBJECT.put("人文英语2","人文英语2");
        SUBJECT.put("美学与美育","美学与美育");
        SUBJECT.put("人文英语1","人文英语1");
        SUBJECT.put("人文英语4","人文英语4");
        SUBJECT.put("城市管理学","城市管理学");
        SUBJECT.put("人文社会科学基础(A)","人文社会科学基础(A)");
        SUBJECT.put("人文英语3","人文英语3");
        SUBJECT.put("建筑工程项目管理","建筑工程项目管理");
        SUBJECT.put("经济数学基础12","经济数学基础12");
        SUBJECT.put("药剂学","药剂学");
        SUBJECT.put("机械设计基础","机械设计基础");
        SUBJECT.put("流通概论","流通概论");
        SUBJECT.put("病理生理学","病理生理学");
        SUBJECT.put("个人与团队管理","个人与团队管理");
        SUBJECT.put("教育心理专题","教育心理专题");
        SUBJECT.put("0-3岁婴幼儿的保育与教育","0-3岁婴幼儿的保育与教育");
        SUBJECT.put("古代汉语专题","古代汉语专题");
        SUBJECT.put("中医药学概论","中医药学概论");
        SUBJECT.put("职业技能实训（一）","职业技能实训（一）");
        SUBJECT.put("混凝土结构设计原理","混凝土结构设计原理");
        SUBJECT.put("学前儿童艺术教育(美术)","学前儿童艺术教育(美术)");
        SUBJECT.put("统计学原理","统计学原理");
        SUBJECT.put("统计学原理（A)","统计学原理（A)");
        SUBJECT.put("学前儿童卫生与保健","学前儿童卫生与保健");
        SUBJECT.put("内科护理学","内科护理学");
        SUBJECT.put("英语教学法","英语教学法");
        SUBJECT.put("管理会计","管理会计");
        SUBJECT.put("文学概论","文学概论");
        SUBJECT.put("知识产权法","知识产权法");
        SUBJECT.put("文论专题","文论专题");
        SUBJECT.put("建筑力学","建筑力学");
        SUBJECT.put("水工建筑物","水工建筑物");
        SUBJECT.put("金融统计分析","金融统计分析");
        SUBJECT.put("应用写作（汉语）","应用写作（汉语）");
        SUBJECT.put("高层建筑施工","高层建筑施工");
        SUBJECT.put("UI设计","UI设计");
        SUBJECT.put("Windows网络操作系统管理","Windows网络操作系统管理");
        SUBJECT.put("管理英语3","管理英语3");
        SUBJECT.put("学前儿童社会教育","学前儿童社会教育");
        SUBJECT.put("中国近现代史纲要","中国近现代史纲要");
        SUBJECT.put("管理英语4","管理英语4");
        SUBJECT.put("个人理财","个人理财");
        SUBJECT.put("管理英语1","管理英语1");
        SUBJECT.put("管理英语2","管理英语2");
        SUBJECT.put("国民经济核算","国民经济核算");
        SUBJECT.put("合同法","合同法");
        SUBJECT.put("建筑结构试验","建筑结构试验");
        SUBJECT.put("建筑施工技术","建筑施工技术");
        SUBJECT.put("建设监理","建设监理");
        SUBJECT.put("比较初等教育","比较初等教育");
        SUBJECT.put("基础写作","基础写作");
        SUBJECT.put("政府经济学","政府经济学");
        SUBJECT.put("形势与政策","形势与政策");
        SUBJECT.put("机电控制工程基础","机电控制工程基础");
        SUBJECT.put("水资源管理","水资源管理");
        SUBJECT.put("经济法律基础","经济法律基础");
        SUBJECT.put("马克思主义基本原理概论","马克思主义基本原理概论");
        SUBJECT.put("水力学(B)","水力学(B)");
        SUBJECT.put("工程经济","工程经济");
        SUBJECT.put("国家开放大学学习指南","国家开放大学学习指南");
        SUBJECT.put("现代教育思想","现代教育思想");
        SUBJECT.put("现代教师学导论","现代教师学导论");
        SUBJECT.put("小学儿童教育心理学","小学儿童教育心理学");
        SUBJECT.put("西方经济学","西方经济学");
        SUBJECT.put("计算机绘图（本）","计算机绘图（本）");
        SUBJECT.put("监督学","监督学");
        SUBJECT.put("传感器与测试技术","传感器与测试技术");
        SUBJECT.put("Web开发基础","Web开发基础");
        SUBJECT.put("中国法律思想史","中国法律思想史");
        SUBJECT.put("中级财务会计（二）","中级财务会计（二）");
        SUBJECT.put("金融学","金融学");
        SUBJECT.put("宪法学","宪法学");
        SUBJECT.put("外国文学专题","外国文学专题");
        SUBJECT.put("液压与气压传动","液压与气压传动");
        SUBJECT.put("习近平新时代中国特色社会主义思想","习近平新时代中国特色社会主义思想");
        SUBJECT.put("酒店管理概论","酒店管理概论");
        SUBJECT.put("网络系统管理与维护","网络系统管理与维护");
        SUBJECT.put("建筑工程估价","建筑工程估价");
        SUBJECT.put("幼儿园课程与活动设计","幼儿园课程与活动设计");
        SUBJECT.put("高等数学基础","高等数学基础");
        SUBJECT.put("C语言程序设计","C语言程序设计");
        SUBJECT.put("习近平法治思想概论","习近平法治思想概论");
        SUBJECT.put("病理学与病理生理学","病理学与病理生理学");
        SUBJECT.put("护理伦理学","护理伦理学");
        SUBJECT.put("企业集团财务管理","企业集团财务管理");
        SUBJECT.put("计算机应用基础","计算机应用基础");
        SUBJECT.put("经济学（本）","经济学（本）");
        SUBJECT.put("学前儿童健康教育","学前儿童健康教育");
        SUBJECT.put("中国古代文学(B)(2)","中国古代文学(B)(2)");
        SUBJECT.put("教育法学","教育法学");
        SUBJECT.put("行政法与行政诉讼法","行政法与行政诉讼法");
        SUBJECT.put("安装工程估价实训","安装工程估价实训");
        SUBJECT.put("行政组织学","行政组织学");
        SUBJECT.put("水利工程施工","水利工程施工");
        SUBJECT.put("中国法制史","中国法制史");
        SUBJECT.put("水利工程测量","水利工程测量");
        SUBJECT.put("课程与教学论","课程与教学论");
        SUBJECT.put("法律文书","法律文书");
        SUBJECT.put("学前儿童发展心理学","学前儿童发展心理学");
        SUBJECT.put("学前儿童艺术教育(音乐)","学前儿童艺术教育(音乐)");
        SUBJECT.put("办公室管理","办公室管理");
        SUBJECT.put("现代教育原理","现代教育原理");
        SUBJECT.put("微机系统与维护","微机系统与维护");
        SUBJECT.put("教育学","教育学");
        SUBJECT.put("综合英语（3）","综合英语（3）");
        SUBJECT.put("机械制造基础","机械制造基础");
        SUBJECT.put("人体解剖生理学","人体解剖生理学");
        SUBJECT.put("工作分析实务","工作分析实务");
        SUBJECT.put("人员招聘与培训实务","人员招聘与培训实务");
        SUBJECT.put("数据库应用技术","数据库应用技术");
        SUBJECT.put("民法学(2)","民法学(2)");
        SUBJECT.put("刑法学(2)","刑法学(2)");
        SUBJECT.put("人体解剖生理学（本）","人体解剖生理学（本）");
        SUBJECT.put("西方行政学说","西方行政学说");
        //SUBJECT.put("毛泽东思想和中国特色社会主义理论体系概论","毛泽东思想和中国特色社会主义理论体系概论");
        SUBJECT.put("Photoshop图像处理","Photoshop图像处理");
        SUBJECT.put("可编程控制器应用实训","可编程控制器应用实训");
        SUBJECT.put("保险学概论","保险学概论");
        SUBJECT.put("工程造价基础","工程造价基础");
        SUBJECT.put("临床医学概论（本）","临床医学概论（本）");
        SUBJECT.put("商务英语3","商务英语3");
        SUBJECT.put("商务英语4","商务英语4");
        SUBJECT.put("课堂提问与引导","课堂提问与引导");
        SUBJECT.put("商务英语1","商务英语1");
        SUBJECT.put("思想道德修养与法律基础","思想道德修养与法律基础");
        SUBJECT.put("商务英语2","商务英语2");
        SUBJECT.put("妇产科学与儿科护理学","妇产科学与儿科护理学");
        SUBJECT.put("建筑制图基础","建筑制图基础");
        SUBJECT.put("Dreamweaver网页设计","Dreamweaver网页设计");
        SUBJECT.put("管理案例分析","管理案例分析");
        SUBJECT.put("资源与运营管理","资源与运营管理");
        SUBJECT.put("机电一体化系统","机电一体化系统");
        SUBJECT.put("工程地质","工程地质");
        SUBJECT.put("经济法","经济法");
        SUBJECT.put("生产与运作管理","生产与运作管理");
        SUBJECT.put("成本会计","成本会计");
        SUBJECT.put("临床药理学","临床药理学");
        SUBJECT.put("金融风险管理","金融风险管理");
        SUBJECT.put("民事诉讼法学","民事诉讼法学");
        SUBJECT.put("刑事诉讼法学","刑事诉讼法学");
        SUBJECT.put("纳税筹划","纳税筹划");
        SUBJECT.put("建筑工程项目招投标与合同管理","建筑工程项目招投标与合同管理");
        SUBJECT.put("教育研究方法","教育研究方法");
        SUBJECT.put("中国现代文学","中国现代文学");
        SUBJECT.put("当代中国政治制度","当代中国政治制度");
        SUBJECT.put("医学统计学","医学统计学");
        SUBJECT.put("公司概论","公司概论");
        SUBJECT.put("企业战略管理","企业战略管理");
        SUBJECT.put("桥梁工程（本）","桥梁工程（本）");
        SUBJECT.put("国际私法","国际私法");
        SUBJECT.put("公共政策概论","公共政策概论");
        SUBJECT.put("优秀广告作品评析","优秀广告作品评析");
        SUBJECT.put("建设法规","建设法规");
        SUBJECT.put("古代汉语(2)","古代汉语(2)");
        SUBJECT.put("金融营销基础","金融营销基础");
        SUBJECT.put("金融风险概论","金融风险概论");
        SUBJECT.put("商业银行经营管理","商业银行经营管理");
        SUBJECT.put("建筑工程估价实训","建筑工程估价实训");
        SUBJECT.put("绩效与薪酬实务","绩效与薪酬实务");
        SUBJECT.put("财经英语","财经英语");
        SUBJECT.put("公共行政学","公共行政学");
        SUBJECT.put("旅游工作者素质修养","旅游工作者素质修养");
        SUBJECT.put("信息化管理与运作","信息化管理与运作");
        SUBJECT.put("管理信息系统","管理信息系统");
        SUBJECT.put("建筑结构","建筑结构");
        SUBJECT.put("劳动关系与社会保障实务","劳动关系与社会保障实务");
        SUBJECT.put("药学信息检索","药学信息检索");
        SUBJECT.put("钢结构（本）","钢结构（本）");
        SUBJECT.put("儿童心理学","儿童心理学");
        SUBJECT.put("工程数学（本）","工程数学（本）");
        SUBJECT.put("人体解剖学与组织胚胎学","人体解剖学与组织胚胎学");
        SUBJECT.put("学前教育学","学前教育学");
        SUBJECT.put("幼儿园课程论","幼儿园课程论");
        SUBJECT.put("财务管理","财务管理");
        SUBJECT.put("社区护理学（本）","社区护理学（本）");
        SUBJECT.put("数据结构（本）","数据结构（本）");
        SUBJECT.put("安装工程估价","安装工程估价");
        SUBJECT.put("古代汉语(1)","古代汉语(1)");
        SUBJECT.put("旅游学概论","旅游学概论");
        SUBJECT.put("儿童发展问题的咨询与辅导","儿童发展问题的咨询与辅导");
        SUBJECT.put("药事管理与法规（本）","药事管理与法规（本）");
        SUBJECT.put("建筑构造","建筑构造");
        SUBJECT.put("离散数学（本）","离散数学（本）");
        SUBJECT.put("汉语通论","汉语通论");
        SUBJECT.put("液压气动技术","液压气动技术");


        Set<String> names = Sets.newHashSet();
        for (File f1 : new File("D:\\newAnswerAll").listFiles()) {
            if (f1.isDirectory()) {
                continue;
            }
            String n = f1.getName();
            names.add(n.substring(0, n.length() - 5));
            System.err.println(n.substring(0, n.length() - 5));
        }

        System.err.println(JSON.toJSONString(SUBJECT.size()));


        login(driver, userName, pwd);

        Thread.sleep(1000);
        Util.switchToFirst(driver);




        for (String id : SUBJECT.keySet()) {
            if(names.contains(id)){
                continue;
            }
            if (Strings.isNullOrEmpty(id)) {
                continue;
            }
            try {
                driver.get("http://thome.ouchn.cn/");
                Thread.sleep(2000);
                String subjectName = SUBJECT.get(id);
                driver.findElement(By.id("txtclassname")).clear();
                Thread.sleep(2000);
                driver.findElement(By.id("txtclassname")).sendKeys(subjectName);
                driver.findElement(By.className("btnblue_m")).click();
                Thread.sleep(5000);


                WebElement course = null;
                int code = -1;
                try {

                    WebElement we = Util.findByCssSelector(driver, "div[id='coursedesignList']");
                    if (we != null) {
                        if (we.getText().contains("暂无信息")) {
                            System.err.println("11111");
                            continue;
                        }
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                    continue;
                }
                System.err.println("2222222222");
                for (WebElement tr : new WebDriverWait(driver, Duration.ofSeconds(20)).until((ExpectedCondition<List<WebElement>>)
                        d -> d.findElements(By.tagName("tr")))) {
                    if (tr.findElements(By.className("bgcolor")).isEmpty()) {
                        System.err.println("33333333333333");
                        continue;
                    }
                    if (!subjectName.equals(tr.findElements(By.className("bgcolor")).get(1).getText().trim())) {
                        System.err.println("44444444444");
                        continue;
                    }
                    int tmp = Integer.parseInt(tr.findElements(By.className("bgcolor")).get(0).getText());
                    System.err.println("tmp:" + tmp);
                    if (tmp > code) {
                        code = tmp;
                        course = tr;
                    }

                }
                if (course != null) {
                    course.findElement(By.tagName("a")).click();
                } else {
                    continue;
                }
                Thread.sleep(5000);
                // ------------FIXME ----

                // 关闭其他页面，只留下当前课程页面
                Util.switchToFirst(driver);
                driver.close();
                Thread.sleep(2000);
                Util.switchToFirst(driver);
                List<Question> questions = Lists.newArrayList();
                // FIXME 如果标题相同就判断不出来了
                //   Set<String> titleSet = Sets.newHashSet();
                Map<String, String> questionAndAnswer = Maps.newHashMap();


                Util.switchToLast(driver);
                // 关闭其他页面，只留下当前课程页面
                Set<Cookie> cookies = driver.manage().getCookies();
                String token = "";
                for (Cookie c : cookies) {
                    if("MoodleSession".equals(c.getName())){
                        token = c.getValue();
                    }
                }
                System.err.println("token:"+token);
                //

                Document doc = SectionImport.getDocument(driver.getCurrentUrl(),userName,token);
                Elements courses = doc.getElementsByClass("course-content");
                //System.out.println(courses.toString());

                if (CollectionsUtil.isEmpty(courses)) {
                    System.out.println("为空");
                    return;
                }
                Element course2 = courses.get(0);
                int sectionCount = 100;
                List<String> lines = new ArrayList<>();
                for (int i = 2;i <= sectionCount;i++) {
                    Element section = course2.getElementById("section-" + i);
                    //System.out.println(section.toString());
                    if (null != section) {
                        Elements instances = section.select("a[class=aalink]");
                        for (Element instance:instances) {
                            String href = instance.attr("href");
                            String instanceName = instance.getElementsByClass("instancename").get(0).ownText();
                            String line = String.format("%s,%s",href,instanceName);
                            System.out.println(line);
                            // FIXME
                            if(line.contains("quiz")){
                                lines.add(line);
                            }
                            // FIXME
                        }
                    }
                }




                for (String urlTask : lines) {
                    try {
                        driver.get(urlTask);
                        Thread.sleep(5000);
                        // Util.switchToLast(driver);

                        System.err.println("z000000000000");
                        String text = driver.findElement(By.className("quizattemptcounts")).getText();

                        System.err.println("z111111111111111");
                        if (!text.contains("您同组内")) {
                            continue;
                        }


                        System.err.println("z22222222222222");
                        driver.findElement(By.className("quizattemptcounts")).findElement(By.tagName("a")).click();
                        Thread.sleep(5000);
                        // 回顾试答
                        // reviewlink
                        List<WebElement> infoList = new WebDriverWait(driver, Duration.ofSeconds(90)).until((ExpectedCondition<List<WebElement>>)
                                d -> d.findElements(By.cssSelector("a[class='reviewlink']")));

                        System.err.println("z33333333333");
                        boolean doubleGoBack = false;

                        int size = 0;
                        if (infoList.size() > 5) {
                            size = 5;
                        } else {
                            size = infoList.size();
                        }


                        //  for (int i = 0; i < infoList.size(); i++) {
                        for (int i = 0; i < size; i++) {
                            new WebDriverWait(driver, Duration.ofSeconds(90)).until((ExpectedCondition<List<WebElement>>)
                                    d -> d.findElements(By.cssSelector("a[class='reviewlink']"))).get(i).click();
                            // FIXME TODO 获取题目信息

                            Thread.sleep(5000);
                            for (WebElement wa : driver.findElements(By.tagName("a"))) {
                                if ("在一页上显示所有试题".equals(wa.getText())) {
                                    doubleGoBack = true;
                                    wa.click();
                                    Thread.sleep(5000);
                                    break;
                                }

                            }


                            for (WebElement singleSubject : Util.getSinglePageQuestionList(driver)) {

                                if (null == singleSubject) {
                                    continue;
                                }
                                String answerClass = singleSubject.getAttribute("class");
                                // informationitem  description description
                                if (Strings.isNullOrEmpty(answerClass)) {
                                    continue;
                                }
                                if (answerClass.contains("description") || answerClass.contains("informationitem")) {
                                    continue;
                                }
                                Question question = new Question();
                                question.setAnalyze("无");
                                question.setDifficult(1);
                                question.setGradeLevel(21);

                                String questionId = singleSubject.getAttribute("id");
                                // 这里的questionId是题目的ID
                                System.err.println("questionId:" + questionId);
                                WebElement contentElement = singleSubject.findElement(By.className("content"));

                                WebElement hiddenElement = singleSubject.
                                        findElement(By.cssSelector("input[type='hidden']"));
                                // 题干
                                String name = hiddenElement.getAttribute("name");
                                System.err.println("name:" + name);
                                // qtext
                                // 题目标题
                                String title = Util.getTitle(contentElement);
                                question.setTitle(title);
                                // FIXME
                                if (questionAndAnswer.containsKey(title)
                                        && !Strings.isNullOrEmpty(questionAndAnswer.get(title))
                                        && questionAndAnswer.get(title).length() > 8  // 进一步排除空的答案；
                                ) {
                                    continue;
                                }
                                // 题目提示 tip prompt
                                WebElement promptElement = Util.findByClassName(contentElement, "prompt");
                                if (null != promptElement) {
                                    System.err.println("promptElement:" + promptElement.getText());
                                }

                                WebElement answerElement = Util.findByClassName(contentElement, "answer");
                                String labelType = "";
                                List<Item> items = Lists.newArrayList();
                                items.clear();
                                if (null != answerElement) {
                                    // 找到每一个选项
                                    // 针对多选和单选和判断题
                                    for (WebElement singleAnswerElement : answerElement.
                                            findElements(By.cssSelector("div[class^='r0'],div[class^='r1']"))) {
                                        // 答案的序号 判断题没有序号 多选和单选有序号
                                        String answerNumber = "";
                                        WebElement numberElement = Util.findByClassName(singleAnswerElement, "answernumber");
                                        if (numberElement != null) {
                                            answerNumber = numberElement.getText();
                                        }
                                        // 每个答案的文本 p标签 =单选和多选 label标签=判断题
                                        String answerContent = Util.getAnswer(singleAnswerElement);
                                        // 找到单选框或复选框
                                        WebElement checkboxElement = singleAnswerElement.
                                                findElement(By.cssSelector("input[type='checkbox'],input[type='radio']"));
                                        labelType = checkboxElement.getAttribute("type");
                                        // 这里的ID是每个选项的ID
                                        // answerContent是每个选项的内容
                                        Item item = new Item();
                                        item.setPrefix(answerNumber);
                                        item.setContent(answerContent);
                                        if (Strings.isNullOrEmpty(answerContent)) {
                                            item.setPrefix(answerContent);
                                        }
                                        items.add(item);
                                    }
                                }


                                // 获取正确答案
                                WebElement rightAnswer = Util.findByClassName(singleSubject, "rightanswer");


                                String answer = null;
                                if (rightAnswer != null) {
                                    //     String[] correctArray = new String[]{rightAnswer.getText()};
                                    answer = Util.getAnswer(rightAnswer);
                                    String[] correctArray = new String[]{answer};
                                    question.setCorrectArray(correctArray);
                                }
                                if (rightAnswer == null) {
                                    rightAnswer = Util.findByClassName(singleSubject, "answer");
                                    if (rightAnswer != null) {
                                        answer = rightAnswer.getText();
                                        String[] correctArray = new String[]{answer};
                                        question.setCorrectArray(correctArray);
                                    }
                                }
                                if (question.getCorrectArray() == null || Strings.isNullOrEmpty(answer) || answer.length() < 5) {
                                    rightAnswer = Util.findByClassName(singleSubject, "generalfeedback");
                                    if (rightAnswer != null) {
                                        //  String[] correctArray = new String[]{Util.getAnswer(rightAnswer)};
                                        answer = rightAnswer.getText();
                                        String[] correctArray = new String[]{answer};
                                        question.setCorrectArray(correctArray);
                                    }
                                }

                                WebElement answerHistoryWe = Util.findByClassName(singleSubject, "generaltable");
                                if (answerHistoryWe != null) {
                                    //  String[] correctArray = new String[]{Util.getAnswer(rightAnswer)};
                                    String answerHistory = answerHistoryWe.getText();
                                    question.setAnswerHistory(answerHistory);
                                }


                                question.setItems(items);

                                //titleSet.add(question.getTitle());
                                questionAndAnswer.put(question.getTitle(), answer);

                                answerClass = singleSubject.getAttribute("class");
                                // 简单题que essay manualgraded notyetanswered
                                if (answerClass.contains("essay")) {
                                    // 等于选项的ID
                                    question.setQuestionType(5);
                                    question.setQuestionTypeDesc("简答题");
                                    question.setCorrect("简单题");
                                    questions.add(question);
                                }
                                // 判断题 que truefalse manualgraded notyetanswered  que truefalse deferredfeedback notyetanswered
                                if (answerClass.contains("truefalse")) {
                                    question.setQuestionType(3);
                                    question.setQuestionTypeDesc("判断题");
                                    questions.add(question);
                                }
                                // 填空题 que shortanswer deferredfeedback notyetanswered
                                if (answerClass.contains("shortanswer") || answerClass.contains("multianswer")) {
                                    // 等于选项的ID
                                    question.setQuestionType(4);
                                    question.setQuestionTypeDesc("填空题");
                                    questions.add(question);
                                }
                                // 多选|单选：que multichoice deferredfeedback notyetanswered
                                if (answerClass.contains("multichoice")) {
                                    if ("radio".equals(labelType)) {
                                        question.setQuestionType(1);
                                        question.setQuestionTypeDesc("单选题");
                                        questions.add(question);
                                    }
                                    if ("checkbox".equals(labelType)) {
                                        question.setQuestionType(2);
                                        question.setQuestionTypeDesc("多选题");
                                        questions.add(question);
                                    }
                                }

                                if (answerClass.contains("multianswer")) {
                                    questions.add(question);
                                }

                                if (answerClass.contains("ddwtos")) {
                                    // 等于选项的ID
                                    question.setQuestionType(10);
                                    question.setQuestionTypeDesc("ddwtos");
                                    questions.add(question);
                                    WebElement rightAnswer222 = Util.findByClassName(singleSubject, "rightanswer");
                                    if (rightAnswer != null) {
                                        //     String[] correctArray = new String[]{rightAnswer.getText()};
                                        String[] correctArray = new String[]{Util.dealContent(rightAnswer222.getText())};
                                        question.setCorrectArray(correctArray);
                                    }
                                }

                                if (answerClass.contains("que match deferredfeedback") // 匹配题目
                                ) {
                                    // 等于选项的ID
                                    WebElement tableWe = contentElement.findElement(By.cssSelector("table[class='answer']"));

                                    List<Item> items1 = Lists.newArrayList();
                                    for (WebElement trWe : tableWe.findElements(By.cssSelector("tr[class='r0'],tr[class='r1']"))) {
                                        Item item = new Item();
                                        item.setContent(trWe.findElement(By.cssSelector("td[class='text']")).getText());
                                        items1.add(item);
                                    }
                                    question.setItems(items1);
                                    question.setQuestionType(61);
                                    question.setQuestionTypeDesc("填空题");
                                    question.setCorrect("匹配题目");
                                    //    question.setCorrect(contentElement.findElement(By.cssSelector("div[clas='rightanswer']")).getText());
                                    questions.add(question);
                                }


                            }
                            Thread.sleep(5000);
                            driver.navigate().back();
                            Thread.sleep(2000);
                            if (doubleGoBack) {
                                driver.navigate().back();
                                Thread.sleep(2000);
                            }

                        }
                        Thread.sleep(2000);
                        //  driver.close();


                    } catch (Exception e) {

                    } finally {
                     try {
                         Util.switchToLast(driver);
                         Thread.sleep(2000);
                     }catch (Exception e2){

                     }
                    }
                }


                Collections.sort(questions);
                List<Map<String, Object>> answers = new ArrayList<>();
                for (Question question : questions) {

                    String title = question.getTitle();
                    title = Util.dealContent(title);
                    Map<String, Object> answerMap = new HashMap<>();
                    answerMap.put("questionType", question.getQuestionType());
                    answerMap.put("answerType", "click");

                    answerMap.put("questionTypeDesc", question.getQuestionTypeDesc());
                    answerMap.put("questionTitle", title);
                    answerMap.put("questionCode", MD5Utils.encode(subjectName + title));
                    answerMap.put("items", question.getItems());
                    answerMap.put("answers", question.getCorrectArray());
                    answerMap.put("answerHistory", question.getAnswerHistory());

                    answers.add(answerMap);
                }

                FileUtils.write(new File("d://newAnswerAll//" + subjectName + ".json"), JSONObject.toJSONString(answers, SerializerFeature.PrettyFormat), "utf-8");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }


        Thread.sleep(12000);
        driver.quit();
    }
}
